<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>父传子</title>
</head>
<body>

<!--
  props属性值类型：
   字符串String
   数值Number
   布尔值Boolean
   数组Array
   对象Object
-->

<div id="app">
  <menu-item></menu-item>
  <menu-item :p-str="pstr"></menu-item>
</div>

<script src="../lib/vue.js"></script>
<script>
  Vue.component('menu-item', {
props: {
  pStr: {
    type: String,
    default: 'Hello Vue',
    validator: function (value) {
      return value.length < 20
    }
  }
},
    template: `
      <div>
        <div>{{typeof pStr}} : {{pStr}}</div>
      </div>`
  })

  let vm = new Vue({
    el: '#app',
    data: {
      pstr: 'Hello World',
    }
  })
</script>

</body>
</html>